package com.aliyun.messagemgt.util;


import com.alibaba.algo.cooperation.common.PagerEntity;
import com.github.pagehelper.PageInfo;

import java.util.List;

/**
 * rpc调用。
 * 映射分页数据
 *
 * @author : WangZhiPan
 * @date : 2021/9/23 16:01
 */
public class PageUtils {


    /**
     * @param pagerEntity
     * @return
     */
    public static PageInfo of(PagerEntity pagerEntity) {
        PageInfo pageInfo = new PageInfo();
        List dataList = pagerEntity.getDataList();
        long total = pagerEntity.getTotal();
        int pageSize = pagerEntity.getPageSize();
        int totalPages = pagerEntity.getTotalPages();
        int pageIndex = pagerEntity.getPageIndex();

        pageInfo.setTotal(total);
        pageInfo.setList(dataList);
        pageInfo.setPageNum(pageIndex);
        pageInfo.setPageSize(pageSize);
        pageInfo.setPages(totalPages);
        return pageInfo;
    }

}
